#ifndef ALP_LIST_H
#define ALP_LIST_H

/**
 * @file alp_list.h
 * @brief List
 */
 
#include "alp_type.h"




/** Abstract type for lists. */
typedef struct alp_list_t alp_list_t;

/** Abstract type for scanning lists. */
typedef struct alp_list_index_t alp_list_index_t;


struct alp_list_t
{
    	alp_list_index_t *first, *last;
};

struct alp_list_index_t
{
	void *data;
	alp_list_index_t *next;
};

/**
 * Create a new list.
 * @param newlist	the list just created
 * @param pool		the pool to allocate the list out of
 * @return 0 for OK
 */
alp_status_t alp_list_create(alp_list_t **newlist);

/**
 * Append an element to a list.
 * @param list	the list
 * @param data	the data to be appended
 * @return 0 for OKs
 */
alp_status_t alp_list_append(alp_list_t *list, void *data);

/**
 * Insert an element to a list's head.
 * @param list	the list
 * @param data	the data to be inserted
 * @return 0 for OK
 */
alp_status_t alp_list_insert(alp_list_t *list, void *data);

/**
 * Get the first element of a list.
 * @param list	the list
 * @return the index for iteration
 */
alp_list_index_t * alp_list_first(alp_list_t *list);

/**
 * Get the next element.
 * @param li	the index for iteration
 * @return the next index
 */
alp_list_index_t * alp_list_next(alp_list_index_t *li);

/**
 * Get the current entry.
 * @param li	the index for iteration
 * @param data	the data for the index
 */
void alp_list_this(alp_list_index_t *li, void **data);


void alp_list_destroy(alp_list_t * list);



#endif
